package com.shensi.api.admin.client.system;

import com.shensi.api.admin.client.fallback.system.SysMenuClientFallBack;
import com.shensi.api.admin.domian.system.vo.RouterVo;
import com.shensi.common.core.constant.CloudConstant;
import com.shensi.common.core.domain.AjaxResult;
import com.shensi.common.core.domain.entity.SysMenu;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Set;

/**
 * @author: budian
 * @since: 2023/11/30
 */
@FeignClient(
        value = CloudConstant.ADMIN_SERVER,
        fallbackFactory = SysMenuClientFallBack.class)
@Component
public interface SysMenuClient {
    /**
     * 获取菜单列表
     */
    @GetMapping("/system/menu/list")
    public AjaxResult list(@SpringQueryMap SysMenu menu);

    /**
     * 根据菜单编号获取详细信息
     */
    @GetMapping(value = "/system/menu/{menuId}")
    public AjaxResult getInfo(@PathVariable("menuId") Long menuId);

    /**
     * 获取菜单下拉树列表
     */
    @GetMapping("/system/menu/treeselect")
    public AjaxResult treeselect(@SpringQueryMap SysMenu menu);

    /**
     * 加载对应角色菜单列表树
     */
    @GetMapping(value = "/system/menu/roleMenuTreeselect/{roleId}")
    public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId);

    /**
     * 新增菜单
     */
    @PostMapping("/system/menu")
    public AjaxResult add(@RequestBody SysMenu menu);

    /**
     * 修改菜单
     */
    @PutMapping("/system/menu")
    public AjaxResult edit(@RequestBody SysMenu menu);

    /**
     * 删除菜单
     */
    @DeleteMapping("/system/menu/{menuId}")
    public AjaxResult remove(@PathVariable("menuId") Long menuId);

    @GetMapping("/system/menu/selectMenuPermsByUserId")
    Set<String> selectMenuPermsByUserId(@RequestParam("userId") Long userId);

    @GetMapping("/system/menu/selectMenuTreeByUserId")
    List<SysMenu> selectMenuTreeByUserId(@RequestParam("userId") Long userId);

    @GetMapping("/system/menu/buildMenus")
    List<RouterVo> buildMenus(@SpringQueryMap List<SysMenu> menus);

    @GetMapping("/system/menu/getRouterByUserId")
    List<RouterVo> getRouterByUserId(@RequestParam("userId") Long userId);
}
